home *** CD-ROM | disk | FTP | other *** search
/ PC User 2003 December / Australian PC User - December 2003 (CD2).iso / software / apps / files / dwmx2k4.exe / Disk1 / data1.cab / Configuration_En / Inspectors / base.js < prev    next >
Encoding:
JavaScript  |  2003-09-05  |  2.8 KB  |  89 lines

  1. // Copyright 2000, 2001, 2002, 2003 Macromedia, Inc. All rights reserved.
  2. // *********** GLOBAL VARS *****************************
  3.  
  4. var helpDoc = MM.HELP_inspBase;
  5.  
  6. // ******************** API ****************************
  7. function canInspectSelection(){
  8.   return true;
  9. }
  10.  
  11. //look at target
  12. //if in list of targets, set to list item
  13. //if not, add to bottom of list and set it
  14.  
  15.  
  16. function inspectSelection(){
  17.   var frameName,counter,frameList,listLen,counter,targetVal,bTargetFound=false;
  18.   var dom = dw.getDocumentDOM();
  19.   var baseObj = dom.getSelectedNode();
  20.  
  21.   if (!baseObj || !baseObj.getAttribute) return;
  22.  
  23.   var hrefVal = baseObj.getAttribute("href");
  24.   var Href = document.Layer1.document.Href;
  25.   var frameTarget = document.Layer1.document.frameTarget;
  26.   var counter=5; //add frame names to picklist after standard frame targets
  27.   //populate frame target picklist
  28.   frameList=getObjectRefs("NS 4.0","parent","frame"); //get list of frames
  29.   if (frameList && frameList.length>0) { //if frames
  30.   //if the frame has a name, add name to target picklist
  31.     for (i=0; i<frameList.length; i++) {
  32.       if (frameList[i].indexOf('unnamed')==-1){ //if the frame has a name
  33.         frameName=frameList[i].substring(frameList[i].indexOf("['")+2,frameList[i].indexOf("']"));
  34.         frameTarget.options[counter++] = new Option(frameName); 
  35.   }}}
  36.  
  37.   //if base target value exists and matches choice in target picklist, set it
  38.   //otherwise, add to bottom of picklist and select it
  39.   if (baseObj.getAttribute("target")){
  40.      targetVal = baseObj.getAttribute("target");
  41.      for (i=0;i<counter&&!bTargetFound;i++){  //look for existing match in frame picklist
  42.        if (targetVal==frameTarget.options[i].text){
  43.          frameTarget.selectedIndex=i;
  44.          bTargetFound=true;
  45.        }
  46.      }
  47.      if (!bTargetFound){ //if no match found
  48.      //dynamically add the frame target value to bottom of picklist
  49.        frameTarget.options[counter] = new Option(targetVal);
  50.        frameTarget.selectedIndex = counter;
  51.      }
  52.   }
  53.   
  54.   //fill in href value
  55.   if (hrefVal)
  56.     Href.value = hrefVal;
  57.   else
  58.     Href.value = "";
  59.  
  60.   showHideTranslated();
  61. //  showHideTranslated( baseObj, 'tButtonSpan' );
  62.     
  63. }
  64.  
  65. // ******************** LOCAL FUNCTIONS ****************************
  66.  
  67. function setBaseTag(){
  68.   var dom = dw.getDocumentDOM();
  69.   var baseObj = dom.getSelectedNode();
  70.   var Href = document.Layer1.document.Href.value;
  71.   var frameTarget = document.Layer1.document.frameTarget;
  72.   var frameIndex = frameTarget.selectedIndex;
  73.   
  74.   if (frameIndex!=0){
  75.     baseObj.setAttribute("target",frameTarget.options[frameIndex].text);
  76.   }else
  77.     baseObj.removeAttribute("target");    
  78.     
  79.   if (Href)
  80.     baseObj.setAttribute("href",Href);   
  81. }
  82.  
  83. function browseForFile(){
  84.   var fileName=browseForFileURL();
  85.   if (fileName) 
  86.     document.Layer1.document.Href.value=fileName;
  87. }
  88.  
  89.